package com.deke.course.controller;


import com.deke.entity.EduSubject;
import com.deke.vo.Result;
import com.deke.course.service.EduSubjectService;
import com.deke.course.vo.SubjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/core/subject")
@Api(tags = "课程分类接口类")
public class CourseSortController {

    @Autowired
    private EduSubjectService subjectService;

    @ApiOperation(value = "根据条件分页查询课程分类信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageCurrent",value = "当前页码"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示的条数"),
    })
    @PostMapping ("/findsubject/{Current}/{pageSize}")
    public Result<List<EduSubject>> findsubject(@RequestBody SubjectVo subjectVo,
                                                @PathVariable(required = true) Integer Current,
                                                @PathVariable(required = true) Integer pageSize
    ){
        return subjectService.findByConditionPage(subjectVo,Current,pageSize);
    }

    @ApiOperation(value = "根据id删除课程分类")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "map",value = "map里边放的id"),
    })
    @PostMapping("/deletesubject")
    public Result deletesubject(@RequestBody Map map){
        Result result = subjectService.deleteSubject(map.get("id").toString());
        return result;
    }

    @PostMapping("/insertsubject")
    public Result insertsubject(@RequestBody EduSubject eduSubject){
        Result result = subjectService.insertSubject(eduSubject);
        return result;
    }
    @PostMapping("/updatesubject")
    public Result updatesubject(@RequestBody EduSubject eduSubject){
        Result result = subjectService.updatesubject(eduSubject);
        return result;
    }
    @PostMapping("/changeStatusId")
    public Result changeStatusId(@RequestBody Map map){
        Result result = subjectService.changeStatusId(map);
        return result;
    }

}
